import styled from 'styled-components';

// 定义断点
const breakpoints = {
  xs: '480px',
  sm: '768px',
  md: '992px',
  lg: '1200px',
  xl: '1600px'
};

// 媒体查询辅助函数
const media = {
  xs: `@media (max-width: ${breakpoints.xs})`,
  sm: `@media (max-width: ${breakpoints.sm})`,
  md: `@media (max-width: ${breakpoints.md})`,
  lg: `@media (max-width: ${breakpoints.lg})`,
  xl: `@media (max-width: ${breakpoints.xl})`
};

export const DashboardContainer = styled.div`
  display: grid;
  grid-template-columns: 0.8fr 1.4fr 0.8fr;
  grid-template-rows: repeat(2, 1fr);
  gap: 20px;
  padding: 20px;
  height: 100vh;
  width: 100vw;
  transition: all 0.3s ease;

  ${media.xl} {
    gap: 15px;
    padding: 15px;
  }

  ${media.lg} {
    gap: 12px;
    padding: 12px;
  }

  ${media.md} {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: 0.8fr 1.4fr 0.8fr;
  }

  ${media.sm} {
    grid-template-columns: 1fr;
    grid-template-rows: 0.8fr 0.8fr 1.4fr 0.8fr 0.8fr;
    gap: 10px;
    padding: 10px;
  }
`;

export const ChartContainer = styled.div`
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 15px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.3s ease;
  min-height: 300px;

  ${media.xl} {
    padding: 12px;
    min-height: 250px;
  }

  ${media.lg} {
    padding: 10px;
    min-height: 200px;
  }

  ${media.md} {
    min-height: 180px;
  }

  ${media.sm} {
    min-height: 150px;
  }
`;

export const LeftTopChart = styled(ChartContainer)`
  grid-column: 1;
  grid-row: 1;
  min-height: 250px;

  ${media.md} {
    grid-column: 1;
    grid-row: 1;
  }

  ${media.sm} {
    grid-column: 1;
    grid-row: 1;
  }
`;

export const LeftBottomChart = styled(ChartContainer)`
  grid-column: 1;
  grid-row: 2;
  min-height: 250px;

  ${media.md} {
    grid-column: 2;
    grid-row: 1;
  }

  ${media.sm} {
    grid-column: 1;
    grid-row: 2;
  }
`;

export const CenterChart = styled(ChartContainer)`
  grid-column: 2;
  grid-row: 1 / span 2;
  min-height: 400px;
  position: relative;
  display: flex;
  flex-direction: column;

  ${media.md} {
    grid-column: 1 / span 2;
    grid-row: 2;
    min-height: 350px;
  }

  ${media.sm} {
    grid-column: 1;
    grid-row: 3;
    min-height: 300px;
  }

  // 确保内容区域填满容器
  > * {
    flex: 1;
    min-height: 0;  // 防止 flex 子元素溢出
  }
`;

export const RightTopChart = styled(ChartContainer)`
  grid-column: 3;
  grid-row: 1;
  min-height: 250px;

  ${media.md} {
    grid-column: 1;
    grid-row: 3;
  }

  ${media.sm} {
    grid-column: 1;
    grid-row: 4;
  }
`;

export const RightBottomChart = styled(ChartContainer)`
  grid-column: 3;
  grid-row: 2;
  min-height: 250px;

  ${media.md} {
    grid-column: 2;
    grid-row: 3;
  }

  ${media.sm} {
    grid-column: 1;
    grid-row: 5;
  }
`; 